package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GameDict;
import com.ruoyi.system.service.IGameDictService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 游戏助手字典 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-05
 */
@Controller
@RequestMapping("/system/gameDict")
public class GameDictController extends BaseController
{
    private String prefix = "system/gameDict";
	
	@Autowired
	private IGameDictService gameDictService;
	
	@RequiresPermissions("system:gameDict:view")
	@GetMapping()
	public String gameDict()
	{
	    return prefix + "/gameDict";
	}
	
	/**
	 * 查询游戏助手字典列表
	 */
	@RequiresPermissions("system:gameDict:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(GameDict gameDict)
	{
		startPage();
        List<GameDict> list = gameDictService.selectGameDictList(gameDict);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出游戏助手字典列表
	 */
	@RequiresPermissions("system:gameDict:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GameDict gameDict)
    {
    	List<GameDict> list = gameDictService.selectGameDictList(gameDict);
        ExcelUtil<GameDict> util = new ExcelUtil<GameDict>(GameDict.class);
        return util.exportExcel(list, "gameDict");
    }
	
	/**
	 * 新增游戏助手字典
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存游戏助手字典
	 */
	@RequiresPermissions("system:gameDict:add")
	@Log(title = "游戏助手字典", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(GameDict gameDict)
	{		
		return toAjax(gameDictService.insertGameDict(gameDict));
	}

	/**
	 * 修改游戏助手字典
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		GameDict gameDict = gameDictService.selectGameDictById(id);
		mmap.put("gameDict", gameDict);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存游戏助手字典
	 */
	@RequiresPermissions("system:gameDict:edit")
	@Log(title = "游戏助手字典", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(GameDict gameDict)
	{		
		return toAjax(gameDictService.updateGameDict(gameDict));
	}
	
	/**
	 * 删除游戏助手字典
	 */
	@RequiresPermissions("system:gameDict:remove")
	@Log(title = "游戏助手字典", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(gameDictService.deleteGameDictByIds(ids));
	}
	
}
